/*
 * @Author: 秦少卫
 * @Date: 2024-04-24 14:07:06
 * @LastEditors: 秦少卫
 * @LastEditTime: 2024-10-07 17:06:16
 * @Description: 用户接口登录
 */

import qs from 'qs';
import axios from 'axios';
import { getLocal } from '@/utils/local';

const baseURL = import.meta.env.APP_APIHOST;

const instance = axios.create({ baseURL });

instance.interceptors.request.use(function (config) {
  const token = getLocal('token');
  if (token) {
    config.headers['Authorization'] = `Bearer ${token}`;
  }
  return config;
});

// 获取相册分类
export const getAlbumCategoryList = () => instance.get('/album/getAlbumCategoryList');

// 获取相册分类
export const getAlbumTemplatePage = (data: any) =>
  instance.get('/album/getAlbumTemplatePage?' + qs.stringify(data));

// 获取用户编辑相册列表
export const getUserAlbumTemplateList = () => instance.get('/album/getUserAlbumTemplateList');

// 获取相册详情
export const getAlbumTemplateDetail = (data: any) =>
  instance.get('/album/getAlbumTemplateDetail?' + qs.stringify(data));

// 保存相册详情
export const saveUserTemplateJson = (data: any) =>
  instance.post('/album/saveUserTemplateJson', data);

// 获取相框分类
export const getImageBoxList = () => instance.get('/sourceMaterial/getList');
